package com.rainng.coursesystem.manager.teacher;

import com.rainng.coursesystem.dao.CourseDAO;
import com.rainng.coursesystem.dao.StudentCourseDAO;
import com.rainng.coursesystem.dao.StudentDAO;
import com.rainng.coursesystem.manager.BaseManager;
import com.rainng.coursesystem.model.bo.StudentCourseItemBO;
import com.rainng.coursesystem.model.entity.StudentCourseEntity;
import org.springframework.stereotype.Component;

import java.util.List;

@Component("teacherStudentCourseManager")
public class TeacherStudentCourseManager extends BaseManager {
    private final StudentCourseDAO studentCourseDAO;
    private final CourseDAO courseDAO;
    private final StudentDAO studentDAO;

    public TeacherStudentCourseManager(StudentCourseDAO studentCourseDAO, CourseDAO courseDAO, StudentDAO studentDAO) {
        this.studentCourseDAO = studentCourseDAO;
        this.courseDAO = courseDAO;
        this.studentDAO = studentDAO;
    }

    public StudentCourseEntity get(Integer id) {
        return studentCourseDAO.get(id);
    }

    public void update(StudentCourseEntity entity) {
        studentCourseDAO.update(entity);
    }

    public boolean isCourseTeacher(Integer courseId, Integer teacherId) {
        return courseDAO.getTeacherIdById(courseId).equals(teacherId);
    }

    public void increaseCourseSelectedCount(Integer courseId) {
        courseDAO.increaseSelectedCount(courseId);
    }

    public List<StudentCourseItemBO> getPage(Integer index, Integer teacherId, String studentName, String courseName, Integer status) {
        return studentCourseDAO.getTeacherStudentCoursePage(index, teacherId, studentName, courseName, status);
    }
} 